<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="author" content="lijun; 67086071; zwlijun@qq.com" />
<title>RIAClient Test</title>
<script language="javascript" type="text/javascript" src="RIAClient.js"></script>
<style>
*{font-size:12px; margin:0px; padding:0px;}
body{margin:10px;}
#VSlide{margin:20px; border:1px solid #8E8E8E; padding:1px; width:550px; height:243px;}
#HSlide{margin:20px; border:1px solid #8E8E8E; padding:1px; width:343px; height:260px;}
#tree{margin:20px;}
ul li{list-style:none;}
p.p{display:block; height:20px; line-height:20px;}
p.p1{display:block; width:300px; float:left; line-height:20px; height:20px;}
div.c-div{width:900px;}
div.c-div2{width:600px;}
</style>
</head>

<body>
 <input type="text" value="168" size="56" /><input type="text" size="4" value="8" /><button onclick="callInterface(this, 1)">fillBefore</button><input type="text" size="56" /><br />
 <input type="text" value="168" size="56" /><input type="text" size="4" value="8" /><button onclick="callInterface(this, 2)">fillAfter</button><input type="text" size="56" /><br />
 <input type="text" value="1234567890.123" size="56" /><input type="text" size="4" value="2" /><button onclick="callInterface(this, 3)">toCurrency</button><input type="text" size="56" /><br /><br />
 <textarea cols="32" rows="5">hi ${name}, welcome to ${place}</textarea><textarea cols="32" rows="5">{'name':'Rex', 'place':'Shenzhen'}</textarea><button onclick="callInterface(this, 4)">format</button><textarea cols="32" rows="5"></textarea><br /><br />
 自动定义滚动面板（垂直）：<button type="button" onclick="doUpdate()">Update</button><br /><br />
 <div id="sp_test"></div>
 <br />
 自动定义滚动面板（水平）：<button type="button" onclick="doUpdate1()">Update</button><br /><br />
 <div id="sp_test1"></div>
 <br />
 <br />
 <div id="s1"></div>
 <div id="v1"></div>
 <div id="s2"></div>
 <div id="v2"></div>
 <br />
 <br />
 <br />
 <div style="height:20px; line-height:20px;">&nbsp;&nbsp;&nbsp;&nbsp;<span id="sel"></span>下拉选择框</div>
 <br />
 <select>
   <option>sfdsfdf</option>
 </select>
 <div id="VSlide"></div>
 <div id="HSlide"></div>
 <div id="tree"></div>
 <br />
 <br />
 <br />
 <button onclick="showDialog('test 01')">click me!</button>
 <button onclick="showDialog('test 02')">click me!</button>
 <button onclick="showDialog('test 03')">click me!</button>
 <button onclick="showDialog('test 04')">click me!</button>
 <button onclick="showDialog('test 05')">click me!</button>
 <select>
   <option>sfdsfdf</option>
 </select>
 <br />
 <br />
 <div style="height:20px; line-height:20px;">&nbsp;&nbsp;&nbsp;&nbsp;<span id="sel2"></span>下拉选择框</div>
 <br />
 <br />
 <br />
</body>

<script type="text/javascript" defer="defer">
function callInterface(obj, type){
var num = obj.previousSibling;
var text = num.previousSibling;
var tar = obj.nextSibling;
switch(type){
    case 1:
        tar.value = (text.value).fillBefore("0", parseInt(num.value, 10));
        break;
    case 2:
        tar.value = (text.value).fillAfter("0", parseInt(num.value, 10));
        break;
    case 3:
        tar.value = (text.value).toCurrency(parseInt(num.value, 10));
        break;
    case 4:
        tar.value = (text.value).format(JSON.string2json(num.value));
        break;
}
}
var sp = new SlidePanel();
sp.init({
    target : "sp_test",
    id : "sp0",
    width : 300,
    height : 120,
    wayWidth : 0,
    wayHeight : 120,
    barWidth : 8,
    barHeight : 20,
    scrollSize : 20,
    layout : sp.RIGHT,
    cssTexts : [
        '#sp_test .slide-panel{background-color:#DEDEDE;}',
        '#sp_test .slide-way{border-left:1px solid #686868; border-right:1px solid #fff;}',
        '#sp_test .slide-bar{background-color:yellow;}',
        '#sp_test .slide-bar-hover{background-color:red;}',
        '#sp_test .slide-bar-dis{background-color:gray;}'
    ]
});
sp.create([
  '<p class="p">今日焦点：给群众贴标签才是别有用心 </p>',
  '<p class="p">今日专栏：连城管局长们都参加非法组织</p>',
  '<p class="p">今日思想：98.6%的中国富豪没问题？</p>',
  '<p class="p">今日社会：如果章子怡裸奔 我也裸奔 </p>',
  '<p class="p">民生日记：宁嫁农民工，不嫁男白领</p>',
  '<p class="p">燕山讲堂：雷颐 制度滞后与清王朝覆亡 </p>',
  '<p class="p">青年发帖举报遭起诉续：获1.68万国家赔偿 </p>',
  '<p class="p">网瘾少年被殴死调查：黑训练营两年盈利千万 </p>',
  '<p class="p">9岁男孩被逼捡垃圾赚钱供其父酗酒(图) </p>',
  '<p class="p">刘德华在官网承认结婚 向粉丝留言《对不起》 </p>',
  '<p class="p">日本大选进入最后冲刺 执政党选情堪忧(图) </p>',
  '<p class="p">胡润发布中国富豪特别报告：10年间17人入狱(图) </p>',
  '<p class="p">浙江规定交通肇事报警非自首 专家称有违刑法 </p>',
  '<p class="p">俄媒称中俄阿尔泰天然气管道建设被无限期冻结 </p>',
  '<p class="p">反价格垄断规定征求意见 价格同盟受法律约束 </p>',
  '<p class="p">发改委要求取消有线电视服务不合理收费 </p>',
  '<p class="p">人大官员称促进社会公平正义将成立法重点 </p>',
  '<p class="p">中石油受益于新定价机制 炼油业务扭亏为盈 </p>'
]);
function doUpdate(){
    sp.updateData([
      '<p class="p">今日焦点：给群众贴标签才是别有用心 </p>',
      '<p class="p">今日专栏：连城管局长们都参加非法组织</p>',
      '<p class="p">今日思想：98.6%的中国富豪没问题？</p>',
      '<p class="p">今日社会：如果章子怡裸奔 我也裸奔 </p>',
      '<p class="p">民生日记：宁嫁农民工，不嫁男白领</p>',
      '<p class="p">燕山讲堂：雷颐 制度滞后与清王朝覆亡 </p>',
      '<p class="p">青年发帖举报遭起诉续：获1.68万国家赔偿 </p>',
      '<p class="p">网瘾少年被殴死调查：黑训练营两年盈利千万 </p>',
      '<p class="p">9岁男孩被逼捡垃圾赚钱供其父酗酒(图) </p>',
      '<p class="p">刘德华在官网承认结婚 向粉丝留言《对不起》 </p>',
      '<p class="p">日本大选进入最后冲刺 执政党选情堪忧(图) </p>',
      '<p class="p">胡润发布中国富豪特别报告：10年间17人入狱(图) </p>',
      '<p class="p">浙江规定交通肇事报警非自首 专家称有违刑法 </p>'
    ]);
}
var sp1 = new SlidePanel();
sp1.init({
    target : "sp_test1",
    id : "sp1",
    width : 300,
    height : 120,
    wayWidth : 300,
    wayHeight : 0,
    barWidth : 20,
    barHeight : 8,
    scrollSize : 20,
    layout : sp1.BOTTOM,
    cssTexts : [
        '#sp_test1 .slide-panel{background-color:#DEDEDE;}',
        '#sp_test1 .slide-way{border-top:1px solid #686868; border-bottom:1px solid #fff;}',
        '#sp_test1 .slide-bar{background-color:yellow;}',
        '#sp_test1 .slide-bar-hover{background-color:red;}',
        '#sp_test1 .slide-bar-dis{background-color:gray;}'
    ]
});
sp1.create([
  '<div class="c-div">',
  '<p class="p1">今日焦点：给群众贴标签才是别有用心 </p>',
  '<p class="p1">今日专栏：连城管局长们都参加非法组织</p>',
  '<p class="p1">今日思想：98.6%的中国富豪没问题？</p>',
  '<p class="p1">今日社会：如果章子怡裸奔 我也裸奔 </p>',
  '<p class="p1">民生日记：宁嫁农民工，不嫁男白领</p>',
  '<p class="p1">燕山讲堂：雷颐 制度滞后与清王朝覆亡 </p>',
  '<p class="p1">青年发帖举报遭起诉续：获1.68万国家赔偿 </p>',
  '<p class="p1">网瘾少年被殴死调查：黑训练营两年盈利千万 </p>',
  '<p class="p1">9岁男孩被逼捡垃圾赚钱供其父酗酒(图) </p>',
  '<p class="p1">刘德华在官网承认结婚 向粉丝留言《对不起》 </p>',
  '<p class="p1">日本大选进入最后冲刺 执政党选情堪忧(图) </p>',
  '<p class="p1">胡润发布中国富豪特别报告：10年间17人入狱(图) </p>',
  '<p class="p1">浙江规定交通肇事报警非自首 专家称有违刑法 </p>',
  '<p class="p1">俄媒称中俄阿尔泰天然气管道建设被无限期冻结 </p>',
  '<p class="p1">反价格垄断规定征求意见 价格同盟受法律约束 </p>',
  '<p class="p1">发改委要求取消有线电视服务不合理收费 </p>',
  '<p class="p1">人大官员称促进社会公平正义将成立法重点 </p>',
  '<p class="p1">中石油受益于新定价机制 炼油业务扭亏为盈 </p>',
  '</div>'
]);
function doUpdate1(){
    sp1.updateData([
      '<div class="c-div2">',
      '<p class="p1">今日焦点：给群众贴标签才是别有用心 </p>',
      '<p class="p1">今日专栏：连城管局长们都参加非法组织</p>',
      '<p class="p1">今日思想：98.6%的中国富豪没问题？</p>',
      '<p class="p1">今日社会：如果章子怡裸奔 我也裸奔 </p>',
      '<p class="p1">民生日记：宁嫁农民工，不嫁男白领</p>',
      '<p class="p1">燕山讲堂：雷颐 制度滞后与清王朝覆亡 </p>',
      '<p class="p1">青年发帖举报遭起诉续：获1.68万国家赔偿 </p>',
      '<p class="p1">网瘾少年被殴死调查：黑训练营两年盈利千万 </p>',
      '<p class="p1">9岁男孩被逼捡垃圾赚钱供其父酗酒(图) </p>',
      '<p class="p1">刘德华在官网承认结婚 向粉丝留言《对不起》 </p>',
      '</div>'
    ]);
}
var arr = [1,32,2,3,3,2,65,86,34,5654,445,33,89];
RIAClient.$E("s1").innerHTML = "排序前：" + arr;
RIAClient.$E("v1").innerHTML = "排序后：" + Sort.HeapSort.sort(arr);
var obj = [
  {index:23, code:"A00123"},
  {index:1, code:"A001232"},
  {index:54, code:"AB0233"},
  {index:33, code:"C00133"},
  {index:4, code:"EF0123"},
  {index:87, code:"GE0133"},
  {index:24, code:"WW0153"},
  {index:7, code:"QDS883"},
  {index:90, code:"SDF143"},
  {index:400, code:"OPU623"},
  {index:323, code:"HG0663"},
  {index:266, code:"GWQD23"}
];
RIAClient.$E("s2").innerHTML = "排序前：" + JSON.json2string(obj);
RIAClient.$E("v2").innerHTML = "排序后：" + JSON.json2string(Sort.HeapSort.sort(obj, "index"));
function doChanged()
{
    alert("event.datatype = " + event.datatype + "\nevent.data = " + event.data + "\n" + "id = " + event.srcElement.id + "\nvalue = " + RIAClient.$E("html_sel_test").value + "\ntext = " + RIAClient.$E("html_sel_test").options[RIAClient.$E("html_sel_test").selectedIndex].text);
}
var jsel = new JSelect();
jsel.setEventHandler({$onchange : doChanged});
jsel.setAttributes({$id:"test", $name:"test", width:200, height:20, offsetX:-2, offsetY:20});
jsel.create("sel");
jsel.add(new JOption("请选择", ""));
jsel.add(new JOption("深圳", "SZ", true, true));
jsel.add(new JOption("北京", "BJ"));
jsel.add(new JOption("上海", "SH"));
jsel.add(new JOption("广州", "GZ"));
jsel.add(new JOption("长沙", "CS"));
jsel.done();

function doChanged2()
{
    alert("event.datatype = " + event.datatype + "\nevent.data = " + event.data + "\n" + "id = " + event.srcElement.id + "\nvalue = " + RIAClient.$E("html_sel_test2").value + "\ntext = " + RIAClient.$E("html_sel_test2").options[RIAClient.$E("html_sel_test2").selectedIndex].text);
}
var jsel2 = new JSelect();
jsel2.setEventHandler({$onchange : doChanged2});
jsel2.setAttributes({$id:"test2", $name:"test2", width:200, height:20, offsetX:-2, offsetY:20});
jsel2.create("sel2");
jsel2.add(new JOption("请选择", ""));
jsel2.add(new JOption("JavaScript", "js", true, true));
jsel2.add(new JOption("Flash", "flash"));
jsel2.add(new JOption("XML", "xml"));
jsel2.add(new JOption("CSS", "css"));
jsel2.add(new JOption("HTML", "html"));
jsel2.done();

var ui = new UIComponent();
 function showDialog(txt){
   ui.dialog({
    title : "RIAClient - 网页对话框",
    width : 400,
    height: 280,
    op_buttons : [
        {op:"CLOSE", handler:null, args:[]}
    ],
    func_buttons : [
        {label:"确定", handler:null, args:[], enabled:true},
        {label:"取消", handler:null, args:[], enabled:true},
        {label:"应用", handler:null, args:[], enabled:false}
    ],
    context : txt
   });
 }
function slideHandler(xmlDoc)
{
    var root = null;
    var slideInstance = null;
    if(null != xmlDoc)
    {
        root = xmlDoc.documentElement;
        var slide = root.childNodes;
        var size = slide.length;
        for(var i = 0; i < size; i++)
        {
            if(1 == slide[i].nodeType && (slide[i].tagName).toLowerCase() == "slide")
            {
                createSlideByXML(slide[i]);
            }
        }
    }
}
function createSlideByXML(slide)
{
    var id = slide.getAttribute("id");
    var type = slide.getAttribute("type");
    var interval = slide.getAttribute("interval");
    var position = slide.getAttribute("position");
    var element = slide.getElementsByTagName("element")[0];
    var oEl = {width:element.getAttribute("width"), height:element.getAttribute("height")};
    var bigImage = slide.getElementsByTagName("bigImage")[0];
    var oBig = {width:bigImage.getAttribute("width"), height:bigImage.getAttribute("height")};
    var smallImage = slide.getElementsByTagName("smallImage")[0];
    var oSmall = {width:smallImage.getAttribute("width"), height:smallImage.getAttribute("height")};
    var items = slide.getElementsByTagName("items")[0];
    var count = items.getAttribute("count");
    var className = items.getAttribute("className");
    var children = items.childNodes;
    var size = children.length;
    var item = null;
    var image = null;
    var big = null;
    var small = null;
    var heading = null;
    var subheading = null;
    var index = 0;
    var instance = new Slide(id, oEl, oBig, oSmall, type, interval);
    instance.createPanel(parseInt(count, 10));
    for(var i = 0; i < size; i++)
    {
        if(1 == children[i].nodeType && (children[i].tagName).toLowerCase() == "item")
        {
            item = children[i];
            image = item.getElementsByTagName("image")[0];
            big = image.getElementsByTagName("big")[0];
            small = image.getElementsByTagName("small")[0];
            heading = item.getElementsByTagName("heading")[0];
            subheading = item.getElementsByTagName("subheading")[0];
            instance.createElement(index, big.getAttribute("src"), small.getAttribute("src"), heading.firstChild.nodeValue, subheading.firstChild.nodeValue, item.getAttribute("link"), item.getAttribute("target"));
            index++;
        }
    }
    instance.showPanel(position);
}
var _xml = new JXML();
slideHandler(_xml.load("slide.xml"));
var xmlTree = new XMLTree();
xmlTree.loadTree("tree.xml");
//alert(xmlTree.node2string(xmlTree.getNode('/tree/root/node[@id="5"]')));
//alert(xmlTree.node2string(xmlTree.getNodes("root")[0]));
/*
var slide = new (new RIAClient()).Slide(0, {width:550, height:243}, {width:343, height:243}, {width:54, height:34}, 0, 4000);
slide.createPanel(5);
slide.createElement(0, "images/_tmp/1.jpg", "images/_tmp/1.jpg", "深圳·第九届高交会", "联想接待MM", "about:blank", "_blank");
slide.createElement(1, "images/_tmp/2.jpg", "images/_tmp/2.jpg", "深圳·第九届高交会", "中天手机模特", "about:blank", "_blank");
slide.createElement(2, "images/_tmp/3.jpg", "images/_tmp/3.jpg", "深圳·第九届高交会", "康佳手机模特001", "about:blank", "_blank");
slide.createElement(3, "images/_tmp/4.jpg", "images/_tmp/4.jpg", "深圳·第九届高交会", "康佳手机模特002", "about:blank", "_blank");
slide.createElement(4, "images/_tmp/5.jpg", "images/_tmp/5.jpg", "深圳·第九届高交会", "康佳手机模特003", "about:blank", "_blank");
slide.showPanel("VSlide");

var slide1 = new (new RIAClient()).Slide(1, {width:343, height:260}, {width:343, height:243}, {width:54, height:34}, 1, 4000);
slide1.createPanel(5);
slide1.createElement(0, "images/_tmp/1.jpg", "images/_tmp/1.jpg", "深圳·第九届高交会", "联想接待MM", "about:blank", "_blank");
slide1.createElement(1, "images/_tmp/2.jpg", "images/_tmp/2.jpg", "深圳·第九届高交会", "中天手机模特", "about:blank", "_blank");
slide1.createElement(2, "images/_tmp/3.jpg", "images/_tmp/3.jpg", "深圳·第九届高交会", "康佳手机模特001", "about:blank", "_blank");
slide1.createElement(3, "images/_tmp/4.jpg", "images/_tmp/4.jpg", "深圳·第九届高交会", "康佳手机模特002", "about:blank", "_blank");
slide1.createElement(4, "images/_tmp/5.jpg", "images/_tmp/5.jpg", "深圳·第九届高交会", "康佳手机模特003", "about:blank", "_blank");
slide1.showPanel("HSlide");
*/
</script>
</html>
